package cn.dnui_xqh414.dnuifood_16110100414.fragment_adapter_and_vhoder;


import java.util.List;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

public class MyFragmentAdapter
        extends FragmentPagerAdapter {

    private List<Fragment> fragments;
    private String[] titles;

    public MyFragmentAdapter(FragmentManager fm,
                             String[] titles,
                             List<Fragment>fragments) {
        super(fm);
        this.titles = titles;
        this.fragments = fragments;
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles[position];
    }

}
